home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / F1Hack / F1Hack Source / AppleFunctionIndex.cp next >
Encoding:
Text File  |  2001-06-23  |  2.0 KB  |  92 lines

  1. // ===========================================================================
  2. //    AppleFunctionIndex.cp         ©1996-1998 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. // Example interface using the LHTTPConnection Class
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <Marklib.h>
  9.  
  10. #include <UInternet.h>
  11. #include <LMailMessage.h>
  12. #include <LURL.h>
  13. #include <UInternetConfig.h>
  14. #include <UModalDialogs.h>
  15.  
  16. #include "AppleFunctionIndex.h"
  17.  
  18.  
  19. // ===========================================================================
  20.  
  21. #pragma mark -
  22. #pragma mark ••• AppleFunctionIndexThread •••
  23.  
  24. void AppleFunctionIndexThread::Start (char *funcName)
  25. {
  26.     AppleFunctionIndexThread    *thread = new AppleFunctionIndexThread (funcName);
  27.  
  28.     thread->Resume();
  29. }
  30.  
  31. AppleFunctionIndexThread::AppleFunctionIndexThread(char *funcName)
  32.         : LThread(false, thread_DefaultStack, threadOption_Default, nil)
  33. {
  34.     strcpy (fFuncName, funcName);
  35. }
  36.  
  37. AppleFunctionIndexThread::~AppleFunctionIndexThread()
  38. {
  39. }
  40.  
  41. void AppleFunctionIndexThread::ListenToMessage(MessageT inMessage, void *ioParam)
  42. {
  43.     inMessage = inMessage;
  44.     ioParam = ioParam;
  45. }
  46.  
  47.  
  48.  
  49. void *AppleFunctionIndexThread::Run(void)
  50. {
  51.     this->MakeURL(fFuncName, fNewURL);
  52.     
  53.     OSStatus        icErr;
  54.     ICInstance        icInst;
  55.     long            selStart,
  56.                     selEnd;
  57.     
  58.     icErr = ICStart(&icInst, 'ALTV');
  59. #if !PP_Target_Carbon
  60.     icErr = ICGeneralFindConfigFile(icInst, true, false, 0, NULL);
  61. #endif
  62.     selStart = 0;
  63.     selEnd = strlen(fNewURL);
  64.     icErr = ICLaunchURL(icInst, NULL, (Ptr) fNewURL, strlen(fNewURL), &selStart, &selEnd);
  65.     icErr = ICStop(icInst);
  66.  
  67.     return nil;
  68. }
  69.  
  70. long AppleFunctionIndexThread::MakeURL (char *funcName, char *newURL)
  71. {
  72.     char        url[1024], urlTemplate[1024];
  73.     unsigned char *c;
  74.     Handle        h = NULL;
  75.     
  76.     strcpy (newURL, funcName);
  77.  
  78.     h = Get1Resource ('STR ', 5000);
  79.     if (ResError()) return -1;
  80.     
  81.     HLock (h);
  82.     c = * (unsigned char **) h;
  83.     memcpy (urlTemplate, c+1, c[0]);
  84.     urlTemplate[c[0]] = 0;
  85.     ReleaseResource (h);
  86.  
  87. //    Get the real URL
  88.     sprintf (newURL, urlTemplate, funcName);
  89.  
  90.     return 0;
  91. }
  92.